package cn.sh.yhk.utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

import javax.annotation.Resource;

/**
 * @Auther: adminyhk
 * @Date: 2018/9/30 10:32
 * @Description:
 */
//@Component
public class MailUtils {
    @Value("${spring.mail.username}")
    String fromMail;
    @Resource
    JavaMailSender javaMailSender;

    /**
     * @param subject      标题
     * @param mailMessage  内容
     * @param maillAddress 邮件地址
     */
    public void sendmail(String subject, String mailMessage, String maillAddress) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(fromMail);
        message.setTo(maillAddress);
        message.setSubject(subject);
        message.setText(mailMessage);
        javaMailSender.send(message);
    }
}
